
dict1=eval(input())
dict2=eval(input())
dict3={}
for i in dict.keys(dict1):
    if i in dict.keys(dict2):
        dict3[i]=dict1[i]+dict2[i]
    else:
        dict3[i]=dict1[i]
for i in dict.keys(dict2):
    if i in dict.keys(dict1):
        dict3[i]=dict1[i]+dict2[i]
    else:
        dict3[i]=dict2[i]
ls1=list()
ls2=list()
for i in dict.keys(dict3):
    if type(i)==type(1):
        ls1.append(str(i)+":"+str(dict3.get(i)))
    else:
        ls2.append(i+":"+str(dict3.get(i)))
ls1.sort()
ls2.sort()
flag=0
print("{",end='')
if len(ls2)!=0:
    for i in ls1:
        print(i,end=',')
else:
    for i in ls1:
        if flag:
            print(",%s"%i,end='')
        else:
            print(i,end='')
            flag=1
    print("}")
    exit()
flag=0
for i in ls2:
    s1=str.split(i,':')
    if flag:
        print(",\"%s\":%s"%(s1[0],s1[1]), end='')
    else:
        print("\"%s\":%s"%(s1[0],s1[1]), end='')
        flag = 1
print("}")